package com.bwie.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bwie.poi.StringUtils;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bwie.mapper.RoomMapper;
import com.bwie.pojo.Room;
import com.bwie.service.RoomService;
/**
 * @Author: zhang
 * @Date:  2025/7/7 17:08
 * @Description: 
 **/
@Service
public class RoomServiceImpl extends ServiceImpl<RoomMapper, Room> implements RoomService{

    @Autowired
    private RoomMapper roomMapper;
    @Override
    public R selectRoomList(PageInfoVo pageInfoVo) {
        Page<Room> roomPage = new Page<>(pageInfoVo.getPageNum(), pageInfoVo.getPageSize());
        Page<Room> roomPage1 = roomMapper.selectRoomList(roomPage, null);
        return R.OK(roomPage1);
    }

    @Override
    public R updateRoomStatus(Room room) {
        if(room.getRoomStatus()==2){
            if(StringUtils.isEmpty(room.getRoomContent())){
                return R.ERROR(500,"请填写驳回描述");
            }
        }
        room.setRoomStatus(room.getRoomStatus());
        room.setRoomContent(room.getRoomContent());
        roomMapper.updateById(room);
        return R.OK();
    }

    @Override
    public R insertRoom(Room room) {
        roomMapper.insert(room);
        return R.OK();
    }
}
